<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<!--

    DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.

    Copyright (c) 1998-2011 Oracle and/or its affiliates. All rights reserved.

    The contents of this file are subject to the terms of either the GNU
    General Public License Version 2 only ("GPL") or the Common Development
    and Distribution License("CDDL") (collectively, the "License").  You
    may not use this file except in compliance with the License.  You can
    obtain a copy of the License at
    https://github.com/payara/Payara/blob/main/LICENSE.txt
    See the License for the specific
    language governing permissions and limitations under the License.

    When distributing the software, include this License Header Notice in each
    file and include the License file at legal/OPEN-SOURCE-LICENSE.txt.

    GPL Classpath Exception:
    Oracle designates this particular file as subject to the "Classpath"
    exception as provided by Oracle in the GPL Version 2 section of the License
    file that accompanied this code.

    Modifications:
    If applicable, add the following below the License Header, with the fields
    enclosed by brackets [] replaced by your own identifying information:
    "Portions Copyright [year] [name of copyright owner]"

    Contributor(s):
    If you wish your version of this file to be governed by only the CDDL or
    only the GPL Version 2, indicate your decision by adding "[Contributor]
    elects to include this software in this distribution under the [CDDL or GPL
    Version 2] license."  If you don't indicate a single choice of license, a
    recipient has the option to distribute your version of this file under
    either the CDDL, the GPL Version 2 or to extend the choice of license to
    its licensees as provided above.  However, if you add GPL Version 2 code
    and therefore, elected the GPL Version 2 license, then the option applies
    only if the new code is made subject to such option by the copyright
    holder.

-->

</head>
<body bgcolor="white">

Provides for <b>implementations of various Stats interfaces.</b> These Stats interfaces
are based on those defined by JSR 77. Besides this, implementations of
various Statistic interfaces are also provided here. A new Statistic is
introduced named <b> StringStatistic </b>.
<P>
When we analyze the Statistic interfaces that are defined by the J2EE Management
Standard, it is evident that they are view-only data structures providing the
accessors for various statistical data, e.g. CountStatistic. Every instance of
CountStatistic is allowed to have only a <EM> getCount </EM> method (in
addition to other meta data accessors), that returns a long. This limits the
usability of these Statistic interfaces by the actual components that gather the
data, because new instances of these interfaces have to be constructed as
and when a query or measurement of that statistic is made. On the other hand, it
is much more flexible to have mutators within implementations of these Statistic
interfaces. But then, there is a possibility that the client who receives
instances of these interfaces inadvertantly changes a particular statistic.
<P>
To solve this problem, this package makes the following provision:
<P>
It defines Statistic classes that have a <i>State</i>. A component that gathers
data has to do the following:
<ul>
    
  <li> Implement the specific Stats interface. e.g. EJBCacheStats. This interface 
    has a method which returns number of beans in cache as an instance of BoundedRangeStatistic. 
  </li>
    
  <li> Initialize an instance of MutableBoundedRangeStatistic with an initial 
    state. This interface exposes all the necessary methods that are required 
    to reflect the change in state. </li>
    
  <li> Since MutableBoundedRangeStatistic provides a method that returns an unmodifiable 
    view of itself, calls the MutableBoundedRangeStatistic.unmodifiableView() 
    which returns BoundedRangeStatistic. This returned value can safely be sent 
    to the caller to which everything is transparent.</li>
</ul>

Note that these Mutable* interfaces/classes are not exposed to clients. Clients 
will only receive instances of Statistics that are part of the J2EE Management 
Standard. 
<h2>Package Specification</h2>
Following Stats interfaces are part of this package. All of these extend the
org.glassfish.j2ee.statistics.Stats interface.
<ul>
  <li>EJBCacheStats</li>
  <li>EJBMethodStats</li>
  <li>EJBPoolStats</li>
  <li>OrbConnectionManagerStats</li>
  <li>OrbThreadPoolStats</li>
  <li>SunOneJVMStats</li>
</ul>

Following new Statistic interfaces are defined by this package. They extend the 
org.glassfish.j2ee.statistics.Statististic interface. 
<ul>
  <li>StringStatistic - A String equivalent of CountStatistic.</li>
  <li>MutableStatistic - A Statistic that has some mutators. It is expected to 
    be handled with care.</li>
  <li>MutableCountStatistic - A CountStatistic/BoundedRangeStatistic that is mutable.</li>
  <li>MutableTimeStatistic - A TimeStatistic that is mutable.</li>
</ul>
<p>Following are the implementations of various Statistic interfaces in org.glassfish.j2ee.statistics 
  package.</p>
<table width="60%" border="1">
  <tr bgcolor="#0066FF"> 
    <td>Interface</td>
    <td>Immutable Implementation (read-only -- for clients)</td>
    <td>Mutable Implementation (read-write -- for core components)</td>
  </tr>
  <tr> 
    <td>CountStatistic</td>
    <td>CountStatisticImpl</td>
    <td>MutableCountStatisticImpl<br>
      It implements MutableCountStatistic.</td>
  </tr>
  <tr> 
    <td>BoundedRangeStatistic</td>
    <td>BoundedRangeStatisticImpl</td>
    <td>MutableBoundedRangeStatisticImpl<br>
      It implements MutableCountStatistic.</td>
  </tr>
  <tr>
    <td>TimeStatistic</td>
    <td>TimeStatisticImpl</td>
    <td>MutableTimeStatisticImpl<br>
      It implements MutableTimeStatistic.</td>
  </tr>
</table>
<p>&nbsp; </p>

Following is a helper implementation done in this package: GenericStatsImpl.
<p>
This class is designed to facilitate the general implementation of {@link
Stats} interface and all the classes that implement this interface can leverage
this class. The main idea is that this class implements:
<ul>
    <li>getStatistic(String)</li>
    <li>getStatistics()</li>
    <li>getStatisticNames()</li>
</ul>
in a reflective manner. Thus, e.g. a specific implementation of EJBPoolStats like
EJBPoolStatsImpl can make use of this class to implement above methods in a
generic manner.
<h2>Related Documentation</h2>

<p>{@link org.glassfish.j2ee.statistics}<br>
  {@link java.util.Collections#unmodifiableMap}<br>
  {@link java.util.Collections#unmodifiableSet}<br>
</p>
<p>@since S1AS8.0 </p>
</body>
</html>
